package initialize

import (
	"fmt"
	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/mysql"
	"goblog/global"
	"os"
)

func Mysql(){

	admin := global.GLOBAL_SERVER.Mysql

	db, err := gorm.Open("mysql", "root:123456@tcp(47.105.145.124:3306)/gblog?charset=utf8&parseTime=True&loc=Local")
	if  err !=nil{
		global.GLOBAL_LOGGER.Error("mysql start error")
		os.Exit(0)  //退出系统
	}else{
		fmt.Println("打开mysql成功")
		global.GLOBAL_DB = db
		global.GLOBAL_DB.LogMode(admin.LogMode)
	}

	fmt.Print("test:",admin)

}